<template>
  <div class="detail-main-box">
    <el-drawer
      :visible.sync="isDrawer"
      :direction="direction"
      :size="this.$store.state.user.userIsPhone ? '90%' : '800px'"
      :with-header="false"
    >
      <div class="drawer-title">
        <div class="drawer-title">记录详情</div>
        <div class="iconfont icon-guanbi" @click="isDrawer = false"></div>
      </div>
      <div class="head-box">
        <div class="identifier-box"></div>
        <div>记录信息</div>
      </div>
      <div class="show-info-box">
        <div class="info-box">
          <div class="left-box">
              <div>
                证书编号：
              </div>
              <div>
                公告编号：
              </div>
              <div>
                证书类型：
              </div>
              <div>
                证书名称：
              </div>
              <div>
                证书简称：
              </div>
              <div>
                证书所属权：
              </div>
              <div>
               证书所属人：
              </div>
              <div>
                发证机关：
              </div>
              <div>
                主要内容：
              </div>
              <div>
                备注：
              </div>
            </div>
          <div class="right-box">
                <div>
                  {{ this.fileCode }}
                </div>
                <div>
                  {{ this.noticeCode }}
                </div>
                <div>
                  {{ this.fileType }}
                </div>
                <div>
                  {{ this.fileName }}
                </div>
                <div>
                 {{ this.fileShortName }}
                </div>
                <div>
                  {{ this.unit }}
                </div>
                <div>
                  {{ this.includPerson }}
                </div>
                <div>
                  {{ this.issueOrgan }}
                </div>
                <div>
                  {{ this.content }}
                </div>
                <div>
                  {{ this.notes }}
                </div>
          </div>
        </div>
        <div class="info-box">
          <div class="left-box">
              <div>
                申请日期：
              </div>
              <div>
                公告日期：
              </div>
              <div>
                下证日期：
              </div>
              <div>
                有效开始日期：
              </div>
              <div>
                有效截至日期：
              </div>
              <div>
                证书是否有效：
              </div>
              <div>
                创建人：
              </div>
              <div>
                创建日期：
              </div>
              <div>
                更新人：
              </div>
              <div>
                更新日期：
              </div>
            </div>
          <div class="right-box">
                <div>
                  {{ this.applyForTime.split('T')[0] }}
                </div>
                <div>
                  {{ this.noticeTime.split('T')[0] }}
                </div>
                <div>
                  {{ this.getTime.split('T')[0] }}
                </div>
                <div>
                  {{ this.beginTime.split('T')[0] }}
                </div>
                <div>
                  {{ this.endTime.split('T')[0] }}
                </div>
                <div>
                  {{ this.isValid ? '有效' : '无效' }}
                </div>
                <div>
                  {{ this.createName }}
                </div>
                <div>
                  {{ this.createTime.split('T')[0] }}
                </div>
                <div>
                  {{ this.updateName ? this.updateName : '' }}
                </div>
                <div>
                  {{ this.updateTime ? this.updateTime.split('T')[0] : '' }}
                </div>
          </div>
        </div>
      </div>  
      
      <div class="anne-box">
        <el-upload
          class="upload-demo"
          :action="uploadUrl"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          :on-success="uploadSuccess"
          :multiple="false"
          disabled
          :file-list="fileList"
        >
        </el-upload>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import fixTime from '@/utils/fixTime.js'
import { getFilesListApi } from '@/api/index'

export default {
  props: {
    drawer: {
      type: Boolean,
      default: false
    },
    projectRow: {
      type: Object,
      default: undefined
    },
    getAnnexListData: {
      type: Function,
      default: undefined
    }
  },
  data () {
    return {
      // 项目编号
      proCode: '',
      // 是否弹出抽屉
      isDrawer: false,
      // 抽屉弹出方向
      direction: 'rtl',
      uploadUrl: 'apis/api/FilesUpload',
      rawData: {},
      // 新增的名称
      fileId: '',
      // 证书编号
      fileCode: '',
      // 公告编码
      noticeCode: '',
      // 新增的名称
      fileName: '',
      // 新增的名称
      fileShortName: '',
      // 主要内容
      content: '',
      // 备注
      notes: '',
      // 申请日期
      applyForTime: '',
      // 申请日期
      noticeTime: '',
      // 获得时间
      getTime: '',
      // 有效开始时间
      beginTime: '',
      // 有效结束时间
      endTime: '',
      // 是否有效
      isValid: false,
      // 获的时间
      unit: '',
      // 获取人
      includPerson: '',
      // 发证机构
      issueOrgan: '',
      // 创建人
      createName: '',
      // 创建时间
      createTime: '',
      // 修改人间
      updateName: '',
      // 修改时间
      updateTime: '',
      // 文件类型
      fileType: '',
      // 有效期
      validityTime: '',
      // 文件列表
      fileList: [],
      // 文件id
      fileGuid: ''
    }
  },

  mounted () {},

  methods: {
    openDrawer (row) {
      console.log('编辑的-----》', row)
      this.rawData = { ...row }
      this.fileCode = row.code  ? row.code : '暂无数据'
      this.fileName = row.shortname ? row.shortname : '暂无数据'
      this.fileType = row.typename ? row.typename : '暂无数据'
      this.validityTime = row.validtime ? row.validtime : '暂无数据'
      this.fileGuid = row.guid ? row.guid : '暂无数据'
      this.fileName = row.name ? row.name : '暂无数据' 
      this.fileShortName = row.shortname ? row.shortname : '暂无数据' 
      this.content = row.maincontent ? row.maincontent : '暂无数据'
      this.notes = row.remark ? row.remark : '暂无数据'
      this.applyForTime = row.applicationdate ? row.applicationdate : '暂无数据'
      this.noticeTime = row.noticetime ? row.noticetime : '暂无数据'
      this.noticeCode = row.noticecode ? row.noticecode : '暂无数据'
      this.getTime = row.gettime ? row.gettime : '暂无数据'
      this.beginTime = row.begintime ? row.begintime : '暂无数据'
      this.endTime = row.finishtime ? row.finishtime : '暂无数据'
      this.unit = row.ownership ? row.ownership : '暂无数据'
      this.includPerson = row.participant ? row.participant : '暂无数据'
      this.issueOrgan = row.certificateorgan ? row.certificateorgan : '暂无数据'
      this.createName = row.creator ? row.creator : '暂无数据'
      this.createTime = row.createtime ? row.createtime : '暂无数据'
      this.updateName = row.updator ? row.updator : '暂无数据'
      this.updateTime = row.updatetime ? row.updatetime : '暂无数据'
      this.isDrawer = true
    },

    // 获取当前项目的文件列表
    async getProFile (code) {
      let data = {
        detailguid: code
      }
      let res = await getFilesListApi(data)
      this.fileList = []
      res.forEach(item => {
        this.fileList.push({
          name: item.name,
          url: item.guid,
          guid: item.guid
        })
      })
    },
    // 文件列表移除文件时的钩子
    handleRemove (file, fileList) {
      return
    },
    // 点击文件列表中已上传的文件时的钩子
    async handlePreview (file) {
      return
    },
    // 限制文件大小
    handleExceed (files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length
        } 个文件`
      )
    },
    // 文件上传成功
    uploadSuccess (response, file, fileList) { 
      
    },
    // 文件删除之前
    beforeRemove (file, fileList) {
      return
    }

  }
}
</script>

<style lang="scss" scoped>
.detail-main-box {
  .drawer-title {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    margin-left: 5px;
    padding: 5px;
    padding-right: 15px;
    font-size: 16px;
    > div {
      font-weight: bold;
    }
    .icon-guanbi:hover {
      cursor: pointer;
    }
  }
  .head-box {
    display: flex;
    align-items: center;
    height: 30px;
    margin-top: 10px;
    margin-bottom: 10px;
    padding-left: 20px;
    font-size: 13px;
    line-height: 30px;
    text-align: start;
    border-bottom: 1px solid #dddcdc;
    .identifier-box {
      width: 5px;
      height: 10px;
      margin-right: 6px;
      background: #11a70c;
    }
  }
  .show-info-box {
    display: flex;
    justify-content: space-around;
    width: 100%;
    .info-box {
    display: flex;
    width: 45%;
    padding-left: 8%;

    /* border: 1px solid red; */
    >div {
      height: 100%;

      /* border: 1px solid green; */
      >div {
        display: flex;
        align-items: center;
        justify-content: space-around;
        height: 30px;
        margin-top: 10px;
      }
    }
    .left-box {
      width: 30%;
      >div {
        justify-content: flex-end;
        font-weight: 400;
        font-size: 14px;
      }
    }
    .right-box {
      width: 60%;
      .file-id-box {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      >div {
        display: flex;
        justify-content: flex-start;
        font-size: 15px;
      }
    }
  }
  }
  .anne-box {
    display: flex;

    /* border: 1px solid red; */
    width: 100%;
    padding-left: 8%;
    .upload-demo {
      /* border: 1px solid red; */
      width: 100%;
      text-align: start;
      .upload-btn {
        color: #000;
        background: rgba($color: #000, $alpha: 0%);
        border: none;
      }
      > ul::-webkit-scrollbar {
        width: 4px;
        height: 8px;
      }
      > ul::-webkit-scrollbar-thumb {
        background: fade(rgb(78 182 214), 60%);
        border-radius: 10px;
        box-shadow: inset 0 0 5px rgb(0 0 0 / 20%);
        opacity: 0.2;
      }
      > ul::-webkit-scrollbar-track {
        background: fade(rgb(78 182 214), 30%);
        border-radius: 0;
        box-shadow: inset 0 0 5px rgb(0 0 0 / 20%);
      }
    }
  }
  .btn-box {
    display: flex;
    justify-content: end;

    /* border: 1px solid #c40f0f; */
    width: 100%;
    margin: 10px 0;
    padding-right: 10px;
    padding-left: 230px;
    > div {
      width: 60px;
      height: 32px;
      margin-left: 10px;
      color: #fff;
      font-size: 12px;
      line-height: 32px;
      text-align: center;
      background: #85ce61;
      border-radius: 5px;
    }
    > div:hover {
      background: rgba($color: #85ce61, $alpha: 80%);
      cursor: pointer;
    }
    .sub-btn {
      color: #fff;
      background: #67c23a;
    }
    .sub-btn:hover {
      color: #fff;
      background: #85ce61;
      border-color: #85ce61;
      cursor: pointer;
    }
    .remove-btn {
      color: #000;
      background: rgba($color: #000, $alpha: 0%);
      border: 1px solid #dcdfe6;
    }
    .remove-btn:hover {
      color: #409eff;
      background-color: #ecf5ff;
      border-color: #c6e2ff;
      cursor: pointer;
    }
  }
}

@media screen and (width <= 768px) {
  .main-box {
    background: #ee0909;
  }
}
</style>